package com.siwei.mes.enums;

import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;

import java.util.Arrays;

/**
 * 砼材的类型对照mes的类型
 * tc的类型   1水泥 2粉煤灰 3矿渣粉 4粗骨料 5细骨料 6外加剂  7其它
 * mes的类型  1-水泥 2-粉煤灰 3-矿渣粉 4-粗骨料 5-细骨料 6-外加剂 7-混凝土
 *
 * @Description: 砼材的类型对照mes的类型
 * @Version: 1.0
 * @author: mlchen
 * @date: 2024/5/23 09:45
 */
@Getter
public enum TcContrastExperimentTypeEnum {
    CEMENT(1, 1, "水泥"),
    FLY(2, 2, "粉煤灰"),
    SLAG(3, 3, "矿渣粉"),
    COARSE(4, 4, "粗骨料"),
    FINE(5, 5, "细骨料"),
    ADMIXTURE(6, 6, "外加剂"),
    CONCRETE(null, 7, "混凝土"),
    OTHER(7, null, "其它");

    @ApiModelProperty(value = "tc的材料类型")
    private final Integer tcType;
    @ApiModelProperty(value = "mes的材料类型")
    private final Integer mesType;
    @ApiModelProperty(value = "类型名称")
    private final String name;

    TcContrastExperimentTypeEnum(Integer tcType, Integer mesType, String name) {
        this.tcType = tcType;
        this.mesType = mesType;
        this.name = name;
    }

    /**
     * 根据砼材类型id查找枚举信息
     *
     * @param tcType 砼材类型
     * @return
     */
    public static TcContrastExperimentTypeEnum selectByTcType(Integer tcType) {
        return Arrays.stream(values()).filter(e -> e.getTcType().equals(tcType)).findFirst().orElse(null);
    }

    /**
     * 根据MES类型id查找枚举信息
     *
     * @param mesType 品控类型
     * @return
     */
    public static TcContrastExperimentTypeEnum selectByMesType(Integer mesType) {
        return Arrays.stream(values()).filter(e -> e.getMesType().equals(mesType)).findFirst().orElse(null);
    }
}
